home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-16 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  50.3 KB  |  1,156 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Quitting,  Next: Prefix Command Arguments,  Prev: Waiting,  Up: Command Loop
  46.  
  47. Quitting
  48. ========
  49.  
  50.    Typing `C-g' while a Lisp function is running causes XEmacs to
  51. "quit" whatever it is doing.  This means that control returns to the
  52. innermost active command loop.
  53.  
  54.    Typing `C-g' while the command loop is waiting for keyboard input
  55. does not cause a quit; it acts as an ordinary input character.  In the
  56. simplest case, you cannot tell the difference, because `C-g' normally
  57. runs the command `keyboard-quit', whose effect is to quit.  However,
  58. when `C-g' follows a prefix key, the result is an undefined key.  The
  59. effect is to cancel the prefix key as well as any prefix argument.
  60.  
  61.    In the minibuffer, `C-g' has a different definition: it aborts out
  62. of the minibuffer.  This means, in effect, that it exits the minibuffer
  63. and then quits.  (Simply quitting would return to the command loop
  64. *within* the minibuffer.)  The reason why `C-g' does not quit directly
  65. when the command reader is reading input is so that its meaning can be
  66. redefined in the minibuffer in this way.  `C-g' following a prefix key
  67. is not redefined in the minibuffer, and it has its normal effect of
  68. canceling the prefix key and prefix argument.  This too would not be
  69. possible if `C-g' always quit directly.
  70.  
  71.    When `C-g' does directly quit, it does so by setting the variable
  72. `quit-flag' to `t'.  XEmacs checks this variable at appropriate times
  73. and quits if it is not `nil'.  Setting `quit-flag' non-`nil' in any way
  74. thus causes a quit.
  75.  
  76.    At the level of C code, quitting cannot happen just anywhere; only
  77. at the special places that check `quit-flag'.  The reason for this is
  78. that quitting at other places might leave an inconsistency in XEmacs's
  79. internal state.  Because quitting is delayed until a safe place,
  80. quitting cannot make XEmacs crash.
  81.  
  82.    Certain functions such as `read-key-sequence' or `read-quoted-char'
  83. prevent quitting entirely even though they wait for input.  Instead of
  84. quitting, `C-g' serves as the requested input.  In the case of
  85. `read-key-sequence', this serves to bring about the special behavior of
  86. `C-g' in the command loop.  In the case of `read-quoted-char', this is
  87. so that `C-q' can be used to quote a `C-g'.
  88.  
  89.    You can prevent quitting for a portion of a Lisp function by binding
  90. the variable `inhibit-quit' to a non-`nil' value.  Then, although `C-g'
  91. still sets `quit-flag' to `t' as usual, the usual result of this--a
  92. quit--is prevented.  Eventually, `inhibit-quit' will become `nil'
  93. again, such as when its binding is unwound at the end of a `let' form.
  94. At that time, if `quit-flag' is still non-`nil', the requested quit
  95. happens immediately.  This behavior is ideal when you wish to make sure
  96. that quitting does not happen within a "critical section" of the
  97. program.
  98.  
  99.    In some functions (such as `read-quoted-char'), `C-g' is handled in
  100. a special way that does not involve quitting.  This is done by reading
  101. the input with `inhibit-quit' bound to `t', and setting `quit-flag' to
  102. `nil' before `inhibit-quit' becomes `nil' again.  This excerpt from the
  103. definition of `read-quoted-char' shows how this is done; it also shows
  104. that normal quitting is permitted after the first character of input.
  105.  
  106.      (defun read-quoted-char (&optional prompt)
  107.        "...DOCUMENTATION..."
  108.        (let ((count 0) (code 0) char)
  109.          (while (< count 3)
  110.            (let ((inhibit-quit (zerop count))
  111.                  (help-form nil))
  112.              (and prompt (message "%s-" prompt))
  113.              (setq char (read-char))
  114.              (if inhibit-quit (setq quit-flag nil)))
  115.            ...)
  116.          (logand 255 code)))
  117.  
  118.  - Variable: quit-flag
  119.      If this variable is non-`nil', then XEmacs quits immediately,
  120.      unless `inhibit-quit' is non-`nil'.  Typing `C-g' ordinarily sets
  121.      `quit-flag' non-`nil', regardless of `inhibit-quit'.
  122.  
  123.  - Variable: inhibit-quit
  124.      This variable determines whether XEmacs should quit when
  125.      `quit-flag' is set to a value other than `nil'.  If `inhibit-quit'
  126.      is non-`nil', then `quit-flag' has no special effect.
  127.  
  128.  - Command: keyboard-quit
  129.      This function signals the `quit' condition with `(signal 'quit
  130.      nil)'.  This is the same thing that quitting does.  (See `signal'
  131.      in *Note Errors::.)
  132.  
  133.    You can specify a character other than `C-g' to use for quitting.
  134. See the function `set-input-mode' in *Note Terminal Input::.
  135.  
  136. 
  137. File: lispref.info,  Node: Prefix Command Arguments,  Next: Recursive Editing,  Prev: Quitting,  Up: Command Loop
  138.  
  139. Prefix Command Arguments
  140. ========================
  141.  
  142.    Most XEmacs commands can use a "prefix argument", a number specified
  143. before the command itself.  (Don't confuse prefix arguments with prefix
  144. keys.)  The prefix argument is at all times represented by a value,
  145. which may be `nil', meaning there is currently no prefix argument.
  146. Each command may use the prefix argument or ignore it.
  147.  
  148.    There are two representations of the prefix argument: "raw" and
  149. "numeric".  The editor command loop uses the raw representation
  150. internally, and so do the Lisp variables that store the information, but
  151. commands can request either representation.
  152.  
  153.    Here are the possible values of a raw prefix argument:
  154.  
  155.    * `nil', meaning there is no prefix argument.  Its numeric value is
  156.      1, but numerous commands make a distinction between `nil' and the
  157.      integer 1.
  158.  
  159.    * An integer, which stands for itself.
  160.  
  161.    * A list of one element, which is an integer.  This form of prefix
  162.      argument results from one or a succession of `C-u''s with no
  163.      digits.  The numeric value is the integer in the list, but some
  164.      commands make a distinction between such a list and an integer
  165.      alone.
  166.  
  167.    * The symbol `-'.  This indicates that `M--' or `C-u -' was typed,
  168.      without following digits.  The equivalent numeric value is -1, but
  169.      some commands make a distinction between the integer -1 and the
  170.      symbol `-'.
  171.  
  172.    We illustrate these possibilities by calling the following function
  173. with various prefixes:
  174.  
  175.      (defun display-prefix (arg)
  176.        "Display the value of the raw prefix arg."
  177.        (interactive "P")
  178.        (message "%s" arg))
  179.  
  180. Here are the results of calling `display-prefix' with various raw
  181. prefix arguments:
  182.  
  183.              M-x display-prefix  -| nil
  184.      
  185.      C-u     M-x display-prefix  -| (4)
  186.      
  187.      C-u C-u M-x display-prefix  -| (16)
  188.      
  189.      C-u 3   M-x display-prefix  -| 3
  190.      
  191.      M-3     M-x display-prefix  -| 3      ; (Same as `C-u 3'.)
  192.      
  193.      C-3     M-x display-prefix  -| 3      ; (Same as `C-u 3'.)
  194.      
  195.      C-u -   M-x display-prefix  -| -
  196.      
  197.      M--     M-x display-prefix  -| -      ; (Same as `C-u -'.)
  198.      
  199.      C--     M-x display-prefix  -| -      ; (Same as `C-u -'.)
  200.      
  201.      C-u - 7 M-x display-prefix  -| -7
  202.      
  203.      M-- 7   M-x display-prefix  -| -7     ; (Same as `C-u -7'.)
  204.      
  205.      C-- 7   M-x display-prefix  -| -7     ; (Same as `C-u -7'.)
  206.  
  207.    XEmacs uses two variables to store the prefix argument: `prefix-arg'
  208. and `current-prefix-arg'.  Commands such as `universal-argument' that
  209. set up prefix arguments for other commands store them in `prefix-arg'.
  210. In contrast, `current-prefix-arg' conveys the prefix argument to the
  211. current command, so setting it has no effect on the prefix arguments
  212. for future commands.
  213.  
  214.    Normally, commands specify which representation to use for the prefix
  215. argument, either numeric or raw, in the `interactive' declaration.
  216. (*Note Using Interactive::.)  Alternatively, functions may look at the
  217. value of the prefix argument directly in the variable
  218. `current-prefix-arg', but this is less clean.
  219.  
  220.  - Function: prefix-numeric-value ARG
  221.      This function returns the numeric meaning of a valid raw prefix
  222.      argument value, ARG.  The argument may be a symbol, a number, or a
  223.      list.  If it is `nil', the value 1 is returned; if it is `-', the
  224.      value -1 is returned; if it is a number, that number is returned;
  225.      if it is a list, the CAR of that list (which should be a number) is
  226.      returned.
  227.  
  228.  - Variable: current-prefix-arg
  229.      This variable holds the raw prefix argument for the *current*
  230.      command.  Commands may examine it directly, but the usual way to
  231.      access it is with `(interactive "P")'.
  232.  
  233.  - Variable: prefix-arg
  234.      The value of this variable is the raw prefix argument for the
  235.      *next* editing command.  Commands that specify prefix arguments for
  236.      the following command work by setting this variable.
  237.  
  238.    Do not call the functions `universal-argument', `digit-argument', or
  239. `negative-argument' unless you intend to let the user enter the prefix
  240. argument for the *next* command.
  241.  
  242.  - Command: universal-argument
  243.      This command reads input and specifies a prefix argument for the
  244.      following command.  Don't call this command yourself unless you
  245.      know what you are doing.
  246.  
  247.  - Command: digit-argument ARG
  248.      This command adds to the prefix argument for the following
  249.      command.  The argument ARG is the raw prefix argument as it was
  250.      before this command; it is used to compute the updated prefix
  251.      argument.  Don't call this command yourself unless you know what
  252.      you are doing.
  253.  
  254.  - Command: negative-argument ARG
  255.      This command adds to the numeric argument for the next command.
  256.      The argument ARG is the raw prefix argument as it was before this
  257.      command; its value is negated to form the new prefix argument.
  258.      Don't call this command yourself unless you know what you are
  259.      doing.
  260.  
  261. 
  262. File: lispref.info,  Node: Recursive Editing,  Next: Disabling Commands,  Prev: Prefix Command Arguments,  Up: Command Loop
  263.  
  264. Recursive Editing
  265. =================
  266.  
  267.    The XEmacs command loop is entered automatically when XEmacs starts
  268. up.  This top-level invocation of the command loop never exits; it keeps
  269. running as long as XEmacs does.  Lisp programs can also invoke the
  270. command loop.  Since this makes more than one activation of the command
  271. loop, we call it "recursive editing".  A recursive editing level has
  272. the effect of suspending whatever command invoked it and permitting the
  273. user to do arbitrary editing before resuming that command.
  274.  
  275.    The commands available during recursive editing are the same ones
  276. available in the top-level editing loop and defined in the keymaps.
  277. Only a few special commands exit the recursive editing level; the others
  278. return to the recursive editing level when they finish.  (The special
  279. commands for exiting are always available, but they do nothing when
  280. recursive editing is not in progress.)
  281.  
  282.    All command loops, including recursive ones, set up all-purpose error
  283. handlers so that an error in a command run from the command loop will
  284. not exit the loop.
  285.  
  286.    Minibuffer input is a special kind of recursive editing.  It has a
  287. few special wrinkles, such as enabling display of the minibuffer and the
  288. minibuffer window, but fewer than you might suppose.  Certain keys
  289. behave differently in the minibuffer, but that is only because of the
  290. minibuffer's local map; if you switch windows, you get the usual XEmacs
  291. commands.
  292.  
  293.    To invoke a recursive editing level, call the function
  294. `recursive-edit'.  This function contains the command loop; it also
  295. contains a call to `catch' with tag `exit', which makes it possible to
  296. exit the recursive editing level by throwing to `exit' (*note Catch and
  297. Throw::.).  If you throw a value other than `t', then `recursive-edit'
  298. returns normally to the function that called it.  The command `C-M-c'
  299. (`exit-recursive-edit') does this.  Throwing a `t' value causes
  300. `recursive-edit' to quit, so that control returns to the command loop
  301. one level up.  This is called "aborting", and is done by `C-]'
  302. (`abort-recursive-edit').
  303.  
  304.    Most applications should not use recursive editing, except as part of
  305. using the minibuffer.  Usually it is more convenient for the user if you
  306. change the major mode of the current buffer temporarily to a special
  307. major mode, which should have a command to go back to the previous mode.
  308. (The `e' command in Rmail uses this technique.)  Or, if you wish to
  309. give the user different text to edit "recursively", create and select a
  310. new buffer in a special mode.  In this mode, define a command to
  311. complete the processing and go back to the previous buffer.  (The `m'
  312. command in Rmail does this.)
  313.  
  314.    Recursive edits are useful in debugging.  You can insert a call to
  315. `debug' into a function definition as a sort of breakpoint, so that you
  316. can look around when the function gets there.  `debug' invokes a
  317. recursive edit but also provides the other features of the debugger.
  318.  
  319.    Recursive editing levels are also used when you type `C-r' in
  320. `query-replace' or use `C-x q' (`kbd-macro-query').
  321.  
  322.  - Function: recursive-edit
  323.      This function invokes the editor command loop.  It is called
  324.      automatically by the initialization of XEmacs, to let the user
  325.      begin editing.  When called from a Lisp program, it enters a
  326.      recursive editing level.
  327.  
  328.      In the following example, the function `simple-rec' first advances
  329.      point one word, then enters a recursive edit, printing out a
  330.      message in the echo area.  The user can then do any editing
  331.      desired, and then type `C-M-c' to exit and continue executing
  332.      `simple-rec'.
  333.  
  334.           (defun simple-rec ()
  335.             (forward-word 1)
  336.             (message "Recursive edit in progress")
  337.             (recursive-edit)
  338.             (forward-word 1))
  339.                => simple-rec
  340.           (simple-rec)
  341.                => nil
  342.  
  343.  - Command: exit-recursive-edit
  344.      This function exits from the innermost recursive edit (including
  345.      minibuffer input).  Its definition is effectively `(throw 'exit
  346.      nil)'.
  347.  
  348.  - Command: abort-recursive-edit
  349.      This function aborts the command that requested the innermost
  350.      recursive edit (including minibuffer input), by signaling `quit'
  351.      after exiting the recursive edit.  Its definition is effectively
  352.      `(throw 'exit t)'.  *Note Quitting::.
  353.  
  354.  - Command: top-level
  355.      This function exits all recursive editing levels; it does not
  356.      return a value, as it jumps completely out of any computation
  357.      directly back to the main command loop.
  358.  
  359.  - Function: recursion-depth
  360.      This function returns the current depth of recursive edits.  When
  361.      no recursive edit is active, it returns 0.
  362.  
  363. 
  364. File: lispref.info,  Node: Disabling Commands,  Next: Command History,  Prev: Recursive Editing,  Up: Command Loop
  365.  
  366. Disabling Commands
  367. ==================
  368.  
  369.    "Disabling a command" marks the command as requiring user
  370. confirmation before it can be executed.  Disabling is used for commands
  371. which might be confusing to beginning users, to prevent them from using
  372. the commands by accident.
  373.  
  374.    The low-level mechanism for disabling a command is to put a
  375. non-`nil' `disabled' property on the Lisp symbol for the command.
  376. These properties are normally set up by the user's `.emacs' file with
  377. Lisp expressions such as this:
  378.  
  379.      (put 'upcase-region 'disabled t)
  380.  
  381. For a few commands, these properties are present by default and may be
  382. removed by the `.emacs' file.
  383.  
  384.    If the value of the `disabled' property is a string, the message
  385. saying the command is disabled includes that string.  For example:
  386.  
  387.      (put 'delete-region 'disabled
  388.           "Text deleted this way cannot be yanked back!\n")
  389.  
  390.    *Note Disabling: (emacs)Disabling, for the details on what happens
  391. when a disabled command is invoked interactively.  Disabling a command
  392. has no effect on calling it as a function from Lisp programs.
  393.  
  394.  - Command: enable-command COMMAND
  395.      Allow COMMAND to be executed without special confirmation from now
  396.      on, and (if the user confirms) alter the user's `.emacs' file so
  397.      that this will apply to future sessions.
  398.  
  399.  - Command: disable-command COMMAND
  400.      Require special confirmation to execute COMMAND from now on, and
  401.      (if the user confirms) alter the user's `.emacs' file so that this
  402.      will apply to future sessions.
  403.  
  404.  - Variable: disabled-command-hook
  405.      This normal hook is run instead of a disabled command, when the
  406.      user invokes the disabled command interactively.  The hook
  407.      functions can use `this-command-keys' to determine what the user
  408.      typed to run the command, and thus find the command itself.  *Note
  409.      Hooks::.
  410.  
  411.      By default, `disabled-command-hook' contains a function that asks
  412.      the user whether to proceed.
  413.  
  414. 
  415. File: lispref.info,  Node: Command History,  Next: Keyboard Macros,  Prev: Disabling Commands,  Up: Command Loop
  416.  
  417. Command History
  418. ===============
  419.  
  420.    The command loop keeps a history of the complex commands that have
  421. been executed, to make it convenient to repeat these commands.  A
  422. "complex command" is one for which the interactive argument reading
  423. uses the minibuffer.  This includes any `M-x' command, any `M-:'
  424. command, and any command whose `interactive' specification reads an
  425. argument from the minibuffer.  Explicit use of the minibuffer during
  426. the execution of the command itself does not cause the command to be
  427. considered complex.
  428.  
  429.  - Variable: command-history
  430.      This variable's value is a list of recent complex commands, each
  431.      represented as a form to evaluate.  It continues to accumulate all
  432.      complex commands for the duration of the editing session, but all
  433.      but the first (most recent) thirty elements are deleted when a
  434.      garbage collection takes place (*note Garbage Collection::.).
  435.  
  436.           command-history
  437.           => ((switch-to-buffer "chistory.texi")
  438.               (describe-key "^X^[")
  439.               (visit-tags-table "~/emacs/src/")
  440.               (find-tag "repeat-complex-command"))
  441.  
  442.    This history list is actually a special case of minibuffer history
  443. (*note Minibuffer History::.), with one special twist: the elements are
  444. expressions rather than strings.
  445.  
  446.    There are a number of commands devoted to the editing and recall of
  447. previous commands.  The commands `repeat-complex-command', and
  448. `list-command-history' are described in the user manual (*note
  449. Repetition: (emacs)Repetition.).  Within the minibuffer, the history
  450. commands used are the same ones available in any minibuffer.
  451.  
  452. 
  453. File: lispref.info,  Node: Keyboard Macros,  Prev: Command History,  Up: Command Loop
  454.  
  455. Keyboard Macros
  456. ===============
  457.  
  458.    A "keyboard macro" is a canned sequence of input events that can be
  459. considered a command and made the definition of a key.  The Lisp
  460. representation of a keyboard macro is a string or vector containing the
  461. events.  Don't confuse keyboard macros with Lisp macros (*note
  462. Macros::.).
  463.  
  464.  - Function: execute-kbd-macro MACRO &optional COUNT
  465.      This function executes MACRO as a sequence of events.  If MACRO is
  466.      a string or vector, then the events in it are executed exactly as
  467.      if they had been input by the user.  The sequence is *not*
  468.      expected to be a single key sequence; normally a keyboard macro
  469.      definition consists of several key sequences concatenated.
  470.  
  471.      If MACRO is a symbol, then its function definition is used in
  472.      place of MACRO.  If that is another symbol, this process repeats.
  473.      Eventually the result should be a string or vector.  If the result
  474.      is not a symbol, string, or vector, an error is signaled.
  475.  
  476.      The argument COUNT is a repeat count; MACRO is executed that many
  477.      times.  If COUNT is omitted or `nil', MACRO is executed once.  If
  478.      it is 0, MACRO is executed over and over until it encounters an
  479.      error or a failing search.
  480.  
  481.  - Variable: executing-macro
  482.      This variable contains the string or vector that defines the
  483.      keyboard macro that is currently executing.  It is `nil' if no
  484.      macro is currently executing.  A command can test this variable to
  485.      behave differently when run from an executing macro.  Do not set
  486.      this variable yourself.
  487.  
  488.  - Variable: defining-kbd-macro
  489.      This variable indicates whether a keyboard macro is being defined.
  490.      A command can test this variable to behave differently while a
  491.      macro is being defined.  The commands `start-kbd-macro' and
  492.      `end-kbd-macro' set this variable--do not set it yourself.
  493.  
  494.  - Variable: last-kbd-macro
  495.      This variable is the definition of the most recently defined
  496.      keyboard macro.  Its value is a string or vector, or `nil'.
  497.  
  498.    The commands are described in the user's manual (*note Keyboard
  499. Macros: (emacs)Keyboard Macros.).
  500.  
  501. 
  502. File: lispref.info,  Node: Keymaps,  Next: Menus,  Prev: Command Loop,  Up: Top
  503.  
  504. Keymaps
  505. *******
  506.  
  507.    The bindings between input events and commands are recorded in data
  508. structures called "keymaps".  Each binding in a keymap associates (or
  509. "binds") an individual event type either with another keymap or with a
  510. command.  When an event is bound to a keymap, that keymap is used to
  511. look up the next input event; this continues until a command is found.
  512. The whole process is called "key lookup".
  513.  
  514.    NOTE: Keymap documentation has not been completely updated for
  515. XEmacs.  Some of the information below is incorrect.
  516.  
  517. * Menu:
  518.  
  519. * Keymap Terminology::            Definitions of terms pertaining to keymaps.
  520. * Format of Keymaps::        What a keymap looks like as a Lisp object.
  521. * Creating Keymaps::         Functions to create and copy keymaps.
  522. * Inheritance and Keymaps::    How one keymap can inherit the bindings
  523.                    of another keymap.
  524. * Prefix Keys::                 Defining a key with a keymap as its definition.
  525. * Active Keymaps::            Each buffer has a local keymap
  526.                                    to override the standard (global) bindings.
  527.                    A minor mode can also override them.
  528. * Key Lookup::                  How extracting elements from keymaps works.
  529. * Functions for Key Lookup::    How to request key lookup.
  530. * Changing Key Bindings::       Redefining a key in a keymap.
  531. * Key Binding Commands::        Interactive interfaces for redefining keys.
  532. * Scanning Keymaps::            Looking through all keymaps, for printing help.
  533.  
  534. 
  535. File: lispref.info,  Node: Keymap Terminology,  Next: Format of Keymaps,  Up: Keymaps
  536.  
  537. Keymap Terminology
  538. ==================
  539.  
  540.    A "keymap" is a table mapping event types to definitions (which can
  541. be any Lisp objects, though only certain types are meaningful for
  542. execution by the command loop).  Given an event (or an event type) and a
  543. keymap, XEmacs can get the event's definition.  Events mapped in keymaps
  544. include keypresses, button presses, and button releases (*note
  545. Events::.).
  546.  
  547.    A sequence of input events that form a unit is called a "key
  548. sequence", or "key" for short.  A sequence of one event is always a key
  549. sequence, and so are some multi-event sequences.
  550.  
  551.    A keymap determines a binding or definition for any key sequence.  If
  552. the key sequence is a single event, its binding is the definition of the
  553. event in the keymap.  The binding of a key sequence of more than one
  554. event is found by an iterative process: the binding of the first event
  555. is found, and must be a keymap; then the second event's binding is found
  556. in that keymap, and so on until all the events in the key sequence are
  557. used up.
  558.  
  559.    If the binding of a key sequence is a keymap, we call the key
  560. sequence a "prefix key".  Otherwise, we call it a "complete key"
  561. (because no more events can be added to it).  If the binding is `nil',
  562. we call the key "undefined".  Examples of prefix keys are `C-c', `C-x',
  563. and `C-x 4'.  Examples of defined complete keys are `X', RET, and `C-x
  564. 4 C-f'.  Examples of undefined complete keys are `C-x C-g', and `C-c
  565. 3'.  *Note Prefix Keys::, for more details.
  566.  
  567.    The rule for finding the binding of a key sequence assumes that the
  568. intermediate bindings (found for the events before the last) are all
  569. keymaps; if this is not so, the sequence of events does not form a
  570. unit--it is not really a key sequence.  In other words, removing one or
  571. more events from the end of any valid key must always yield a prefix
  572. key.  For example, `C-f C-n' is not a key; `C-f' is not a prefix key,
  573. so a longer sequence starting with `C-f' cannot be a key.
  574.  
  575.    Note that the set of possible multi-event key sequences depends on
  576. the bindings for prefix keys; therefore, it can be different for
  577. different keymaps, and can change when bindings are changed.  However,
  578. a one-event sequence is always a key sequence, because it does not
  579. depend on any prefix keys for its well-formedness.
  580.  
  581.    At any time, several primary keymaps are "active"--that is, in use
  582. for finding key bindings.  These are the "global map", which is shared
  583. by all buffers; the "local keymap", which is usually associated with a
  584. specific major mode; and zero or more "minor mode keymaps", which
  585. belong to currently enabled minor modes.  (Not all minor modes have
  586. keymaps.)  The local keymap bindings shadow (i.e., take precedence
  587. over) the corresponding global bindings.  The minor mode keymaps shadow
  588. both local and global keymaps.  *Note Active Keymaps::, for details.
  589.  
  590. 
  591. File: lispref.info,  Node: Format of Keymaps,  Next: Creating Keymaps,  Prev: Keymap Terminology,  Up: Keymaps
  592.  
  593. Format of Keymaps
  594. =================
  595.  
  596.    A keymap is a primitive type that associates events with their
  597. bindings.  Note that this is different from Emacs 18 and FSF Emacs,
  598. where keymaps are lists.
  599.  
  600.  - Function: keymapp OBJECT
  601.      This function returns `t' if OBJECT is a keymap, `nil' otherwise.
  602.  
  603. 
  604. File: lispref.info,  Node: Creating Keymaps,  Next: Inheritance and Keymaps,  Prev: Format of Keymaps,  Up: Keymaps
  605.  
  606. Creating Keymaps
  607. ================
  608.  
  609.    Here we describe the functions for creating keymaps.
  610.  
  611.  - Function: make-keymap
  612.      This function constructs and returns a new keymap object.  All
  613.      entries in it are `nil', meaning "command undefined".
  614.  
  615.  - Function: make-sparse-keymap
  616.      This function constructs and returns a new keymap object.  All
  617.      entries in it are `nil', meaning "command undefined".  The only
  618.      difference between this function and `make-keymap' is that this
  619.      function returns a "smaller" keymap (one that is expected to
  620.      contain fewer entries).  As keymaps dynamically resize, the
  621.      distinction is not great.
  622.  
  623.  - Function: copy-keymap KEYMAP
  624.      This function returns a copy of KEYMAP.  Any keymaps that appear
  625.      directly as bindings in KEYMAP are also copied recursively, and so
  626.      on to any number of levels.  However, recursive copying does not
  627.      take place when the definition of a character is a symbol whose
  628.      function definition is a keymap; the same symbol appears in the
  629.      new copy.
  630.  
  631.           (setq map (copy-keymap (current-local-map)))
  632.           => #<keymap 3 entries 0x21f80>
  633.           
  634.           (eq map (current-local-map))
  635.               => nil
  636.  
  637. 
  638. File: lispref.info,  Node: Inheritance and Keymaps,  Next: Prefix Keys,  Prev: Creating Keymaps,  Up: Keymaps
  639.  
  640. Inheritance and Keymaps
  641. =======================
  642.  
  643.    A keymap can inherit the bindings of other keymaps.  The other
  644. keymaps are called the keymap's "parents", and are set with
  645. `set-keymap-parents'.  When searching for a binding for a key sequence
  646. in a particular keymap, that keymap itself will first be searched;
  647. then, if no binding was found in the map and it has parents, the first
  648. parent keymap will be searched; then that keymap's parent will be
  649. searched, and so on, until either a binding for the key sequence is
  650. found, or a keymap without a parent is encountered.  At this point, the
  651. search will continue with the next parent of the most recently
  652. encountered keymap that has another parent, etc.  Essentially, a
  653. depth-first search of all the ancestors of the keymap is conducted.
  654.  
  655.    `(current-global-map)' is the default parent of all keymaps.
  656.  
  657.  - Function: set-keymap-parents KEYMAP PARENTS
  658.      This function sets the parent keymaps of KEYMAP to the list
  659.      PARENTS.
  660.  
  661.      If you change the bindings in one of the keymaps in PARENTS using
  662.      `define-key' or other key-binding functions, these changes are
  663.      visible in KEYMAP unless shadowed by bindings in that map or in
  664.      earlier-searched ancestors.  The converse is not true: if you use
  665.      `define-key' to change KEYMAP, that affects the bindings in that
  666.      map, but has no effect on any of the keymaps in PARENTS.
  667.  
  668.  - Function: keymap-parents KEYMAP
  669.      This function returns the list of parent keymaps of KEYMAP, or
  670.      `nil' if KEYMAP has no parents.
  671.  
  672. 
  673. File: lispref.info,  Node: Prefix Keys,  Next: Active Keymaps,  Prev: Inheritance and Keymaps,  Up: Keymaps
  674.  
  675. Prefix Keys
  676. ===========
  677.  
  678.    A "prefix key" has an associated keymap that defines what to do with
  679. key sequences that start with the prefix key.  For example, `C-x' is a
  680. prefix key, and it uses a keymap that is also stored in the variable
  681. `ctl-x-map'.  Here is a list of the standard prefix keys of XEmacs and
  682. their keymaps:
  683.  
  684.    * `help-map' is used for events that follow `C-h'.
  685.  
  686.    * `mode-specific-map' is for events that follow `C-c'.  This map is
  687.      not actually mode specific; its name was chosen to be informative
  688.      for the user in `C-h b' (`display-bindings'), where it describes
  689.      the main use of the `C-c' prefix key.
  690.  
  691.    * `ctl-x-map' is the map used for events that follow `C-x'.  This
  692.      map is also the function definition of `Control-X-prefix'.
  693.  
  694.    * `ctl-x-4-map' is used for events that follow `C-x 4'.
  695.  
  696.    * `ctl-x-5-map' is used for events that follow `C-x 5'.
  697.  
  698.    * The prefix keys `C-x n', `C-x r' and `C-x a' use keymaps that have
  699.      no special name.
  700.  
  701.    * `esc-map' is an evil hack that is present for compatibility
  702.      purposes with Emacs 18.  Defining a key in `esc-map' is equivalent
  703.      to defining the same key in `global-map' but with the META prefix
  704.      added.  You should *not* use this in your code. (This map is also
  705.      the function definition of `ESC-prefix'.)
  706.  
  707.    The binding of a prefix key is the keymap to use for looking up the
  708. events that follow the prefix key.  (It may instead be a symbol whose
  709. function definition is a keymap.  The effect is the same, but the symbol
  710. serves as a name for the prefix key.)  Thus, the binding of `C-x' is
  711. the symbol `Control-X-prefix', whose function definition is the keymap
  712. for `C-x' commands.  (The same keymap is also the value of `ctl-x-map'.)
  713.  
  714.    Prefix key definitions can appear in any active keymap.  The
  715. definitions of `C-c', `C-x', `C-h' and ESC as prefix keys appear in the
  716. global map, so these prefix keys are always available.  Major and minor
  717. modes can redefine a key as a prefix by putting a prefix key definition
  718. for it in the local map or the minor mode's map.  *Note Active
  719. Keymaps::.
  720.  
  721.    If a key is defined as a prefix in more than one active map, then its
  722. various definitions are in effect merged: the commands defined in the
  723. minor mode keymaps come first, followed by those in the local map's
  724. prefix definition, and then by those from the global map.
  725.  
  726.    In the following example, we make `C-p' a prefix key in the local
  727. keymap, in such a way that `C-p' is identical to `C-x'.  Then the
  728. binding for `C-p C-f' is the function `find-file', just like `C-x C-f'.
  729. The key sequence `C-p 6' is not found in any active keymap.
  730.  
  731.      (use-local-map (make-sparse-keymap))
  732.          => nil
  733.      (local-set-key "\C-p" ctl-x-map)
  734.          => nil
  735.      (key-binding "\C-p\C-f")
  736.          => find-file
  737.      
  738.      (key-binding "\C-p6")
  739.          => nil
  740.  
  741.  - Function: define-prefix-command SYMBOL &optional MAPVAR
  742.      This function defines SYMBOL as a prefix command: it creates a
  743.      keymap and stores it as SYMBOL's function definition.  Storing the
  744.      symbol as the binding of a key makes the key a prefix key that has
  745.      a name.  If optional argument MAPVAR is not specified, it also
  746.      sets SYMBOL as a variable, to have the keymap as its value. (If
  747.      MAPVAR is given and is not `t', its value is stored as the value
  748.      of SYMBOL.) The function returns SYMBOL.
  749.  
  750.      In Emacs version 18, only the function definition of SYMBOL was
  751.      set, not the value as a variable.
  752.  
  753. 
  754. File: lispref.info,  Node: Active Keymaps,  Next: Key Lookup,  Prev: Prefix Keys,  Up: Keymaps
  755.  
  756. Active Keymaps
  757. ==============
  758.  
  759.    XEmacs normally contains many keymaps; at any given time, just a few
  760. of them are "active" in that they participate in the interpretation of
  761. user input.  These are the global keymap, the current buffer's local
  762. keymap, and the keymaps of any enabled minor modes.
  763.  
  764.    The "global keymap" holds the bindings of keys that are defined
  765. regardless of the current buffer, such as `C-f'.  The variable
  766. `global-map' holds this keymap, which is always active.
  767.  
  768.    Each buffer may have another keymap, its "local keymap", which may
  769. contain new or overriding definitions for keys.  The current buffer's
  770. local keymap is always active except when `overriding-local-map'
  771. overrides it.  Text properties can specify an alternative local map for
  772. certain parts of the buffer; see *Note Special Properties::.
  773.  
  774.    Each minor mode may have a keymap; if it does, the keymap is active
  775. when the minor mode is enabled.
  776.  
  777.    The variable `overriding-local-map', if non-`nil', specifies another
  778. local keymap that overrides the buffer's local map and all the minor
  779. mode keymaps.
  780.  
  781.    All the active keymaps are used together to determine what command to
  782. execute when a key is entered.  XEmacs searches these maps one by one,
  783. in order of decreasing precedence, until it finds a binding in one of
  784. the maps.
  785.  
  786.    Normally, XEmacs *first* searches for the key in the minor mode maps
  787. (one map at a time); if they do not supply a binding for the key,
  788. XEmacs searches the local map; if that too has no binding, Emacs then
  789. searches the global map.  However, if `overriding-local-map' is
  790. non-`nil', XEmacs searches that map first, followed by the global map.
  791.  
  792.    The procedure for searching a single keymap is called "key lookup";
  793. see *Note Key Lookup::.
  794.  
  795.    Since every buffer that uses the same major mode normally uses the
  796. same local keymap, you can think of the keymap as local to the mode.  A
  797. change to the local keymap of a buffer (using `local-set-key', for
  798. example) is seen also in the other buffers that share that keymap.
  799.  
  800.    The local keymaps that are used for Lisp mode, C mode, and several
  801. other major modes exist even if they have not yet been used.  These
  802. local maps are the values of the variables `lisp-mode-map',
  803. `c-mode-map', and so on.  For most other modes, which are less
  804. frequently used, the local keymap is constructed only when the mode is
  805. used for the first time in a session.
  806.  
  807.    The minibuffer has local keymaps, too; they contain various
  808. completion and exit commands.  *Note Intro to Minibuffers::.
  809.  
  810.    *Note Standard Keymaps::, for a list of standard keymaps.
  811.  
  812.  - Variable: global-map
  813.      This variable contains the default global keymap that maps XEmacs
  814.      keyboard input to commands.  The global keymap is normally this
  815.      keymap.  The default global keymap is a full keymap that binds
  816.      `self-insert-command' to all of the printing characters.
  817.  
  818.      It is normal practice to change the bindings in the global map,
  819.      but you should not assign this variable any value other than the
  820.      keymap it starts out with.
  821.  
  822.  - Function: current-global-map
  823.      This function returns the current global keymap.  This is the same
  824.      as the value of `global-map' unless you change one or the other.
  825.  
  826.           (current-global-map)
  827.           => (keymap [set-mark-command beginning-of-line ...
  828.                       delete-backward-char])
  829.  
  830.  - Function: current-local-map
  831.      This function returns the current buffer's local keymap, or `nil'
  832.      if it has none.  In the following example, the keymap for the
  833.      `*scratch*' buffer (using Lisp Interaction mode) is a sparse keymap
  834.      in which the entry for ESC, ASCII code 27, is another sparse
  835.      keymap.
  836.  
  837.           (current-local-map)
  838.           => (keymap
  839.               (10 . eval-print-last-sexp)
  840.               (9 . lisp-indent-line)
  841.               (127 . backward-delete-char-untabify)
  842.               (27 keymap
  843.                   (24 . eval-defun)
  844.                   (17 . indent-sexp)))
  845.  
  846.  - Function: current-minor-mode-maps
  847.      This function returns a list of the keymaps of currently enabled
  848.      minor modes.
  849.  
  850.  - Function: use-global-map KEYMAP
  851.      This function makes KEYMAP the new current global keymap.  It
  852.      returns `nil'.
  853.  
  854.      It is very unusual to change the global keymap.
  855.  
  856.  - Function: use-local-map KEYMAP
  857.      This function makes KEYMAP the new local keymap of the current
  858.      buffer.  If KEYMAP is `nil', then the buffer has no local keymap.
  859.      `use-local-map' returns `nil'.  Most major mode commands use this
  860.      function.
  861.  
  862.  - Variable: minor-mode-map-alist
  863.      This variable is an alist describing keymaps that may or may not be
  864.      active according to the values of certain variables.  Its elements
  865.      look like this:
  866.  
  867.           (VARIABLE . KEYMAP)
  868.  
  869.      The keymap KEYMAP is active whenever VARIABLE has a non-`nil'
  870.      value.  Typically VARIABLE is the variable that enables or
  871.      disables a minor mode.  *Note Keymaps and Minor Modes::.
  872.  
  873.      Note that elements of `minor-mode-map-alist' do not have the same
  874.      structure as elements of `minor-mode-alist'.  The map must be the
  875.      CDR of the element; a list with the map as the second element will
  876.      not do.
  877.  
  878.      What's more, the keymap itself must appear in the CDR.  It does not
  879.      work to store a variable in the CDR and make the map the value of
  880.      that variable.
  881.  
  882.      When more than one minor mode keymap is active, their order of
  883.      priority is the order of `minor-mode-map-alist'.  But you should
  884.      design minor modes so that they don't interfere with each other.
  885.      If you do this properly, the order will not matter.
  886.  
  887.      See also `minor-mode-key-binding', above.  See *Note Keymaps and
  888.      Minor Modes::, for more information about minor modes.
  889.  
  890.  - Variable: overriding-local-map
  891.      If non-`nil', this variable holds a keymap to use instead of the
  892.      buffer's local keymap and instead of all the minor mode keymaps.
  893.      This keymap, if any, overrides all other maps that would have been
  894.      active, except for the current global map.
  895.  
  896.  - Variable: overriding-local-map-menu-flag
  897.      If this variable is non-`nil', the value of `overriding-local-map'
  898.      can affect the display of the menu bar.  The default value is
  899.      `nil', so `overriding-local-map' has no effect on the menu bar.
  900.  
  901.      Note that `overriding-local-map' does affect the execution of key
  902.      sequences entered using the menu bar, even if it does not affect
  903.      the menu bar display.  So if a menu bar key sequence comes in, you
  904.      should clear `overriding-local-map' before looking up and
  905.      executing that key sequence.  Modes that use
  906.      `overriding-local-map' would typically do this anyway; normally
  907.      they respond to events that they do not handle by "unreading" them
  908.      and exiting.
  909.  
  910. 
  911. File: lispref.info,  Node: Key Lookup,  Next: Functions for Key Lookup,  Prev: Active Keymaps,  Up: Keymaps
  912.  
  913. Key Lookup
  914. ==========
  915.  
  916.    "Key lookup" is the process of finding the binding of a key sequence
  917. from a given keymap.  Actual execution of the binding is not part of
  918. key lookup.
  919.  
  920.    Key lookup uses just the event type of each event in the key
  921. sequence; the rest of the event is ignored.  In fact, a key sequence
  922. used for key lookup may designate mouse events with just their types
  923. (symbols) instead of with entire mouse events (lists).  *Note Events::.
  924. Such a pseudo-key-sequence is insufficient for `command-execute', but
  925. it is sufficient for looking up or rebinding a key.
  926.  
  927.    When the key sequence consists of multiple events, key lookup
  928. processes the events sequentially: the binding of the first event is
  929. found, and must be a keymap; then the second event's binding is found in
  930. that keymap, and so on until all the events in the key sequence are used
  931. up.  (The binding thus found for the last event may or may not be a
  932. keymap.)  Thus, the process of key lookup is defined in terms of a
  933. simpler process for looking up a single event in a keymap.  How that is
  934. done depends on the type of object associated with the event in that
  935. keymap.
  936.  
  937.    Let's use the term "keymap entry" to describe the value found by
  938. looking up an event type in a keymap.  (This doesn't include the item
  939. string and other extra elements in menu key bindings because
  940. `lookup-key' and other key lookup functions don't include them in the
  941. returned value.)  While any Lisp object may be stored in a keymap as a
  942. keymap entry, not all make sense for key lookup.  Here is a list of the
  943. meaningful kinds of keymap entries:
  944.  
  945. `nil'
  946.      `nil' means that the events used so far in the lookup form an
  947.      undefined key.  When a keymap fails to mention an event type at
  948.      all, and has no default binding, that is equivalent to a binding
  949.      of `nil' for that event type.
  950.  
  951. KEYMAP
  952.      The events used so far in the lookup form a prefix key.  The next
  953.      event of the key sequence is looked up in KEYMAP.
  954.  
  955. COMMAND
  956.      The events used so far in the lookup form a complete key, and
  957.      COMMAND is its binding.  *Note What Is a Function::.
  958.  
  959. ARRAY
  960.      The array (either a string or a vector) is a keyboard macro.  The
  961.      events used so far in the lookup form a complete key, and the
  962.      array is its binding.  See *Note Keyboard Macros::, for more
  963.      information.
  964.  
  965. LIST
  966.      The meaning of a list depends on the types of the elements of the
  967.      list.
  968.  
  969.         * If the CAR of LIST is the symbol `keymap', then the list is a
  970.           keymap, and is treated as a keymap (see above).
  971.  
  972.         * If the CAR of LIST is `lambda', then the list is a lambda
  973.           expression.  This is presumed to be a command, and is treated
  974.           as such (see above).
  975.  
  976.         * If the CAR of LIST is a keymap and the CDR is an event type,
  977.           then this is an "indirect entry":
  978.  
  979.                (OTHERMAP . OTHERTYPE)
  980.  
  981.           When key lookup encounters an indirect entry, it looks up
  982.           instead the binding of OTHERTYPE in OTHERMAP and uses that.
  983.  
  984.           This feature permits you to define one key as an alias for
  985.           another key.  For example, an entry whose CAR is the keymap
  986.           called `esc-map' and whose CDR is 32 (the code for SPC)
  987.           means, "Use the global binding of `Meta-SPC', whatever that
  988.           may be."
  989.  
  990. SYMBOL
  991.      The function definition of SYMBOL is used in place of SYMBOL.  If
  992.      that too is a symbol, then this process is repeated, any number of
  993.      times.  Ultimately this should lead to an object that is a keymap,
  994.      a command or a keyboard macro.  A list is allowed if it is a
  995.      keymap or a command, but indirect entries are not understood when
  996.      found via symbols.
  997.  
  998.      Note that keymaps and keyboard macros (strings and vectors) are not
  999.      valid functions, so a symbol with a keymap, string, or vector as
  1000.      its function definition is invalid as a function.  It is, however,
  1001.      valid as a key binding.  If the definition is a keyboard macro,
  1002.      then the symbol is also valid as an argument to `command-execute'
  1003.      (*note Interactive Call::.).
  1004.  
  1005.      The symbol `undefined' is worth special mention: it means to treat
  1006.      the key as undefined.  Strictly speaking, the key is defined, and
  1007.      its binding is the command `undefined'; but that command does the
  1008.      same thing that is done automatically for an undefined key: it
  1009.      rings the bell (by calling `ding') but does not signal an error.
  1010.  
  1011.      `undefined' is used in local keymaps to override a global key
  1012.      binding and make the key "undefined" locally.  A local binding of
  1013.      `nil' would fail to do this because it would not override the
  1014.      global binding.
  1015.  
  1016. ANYTHING ELSE
  1017.      If any other type of object is found, the events used so far in the
  1018.      lookup form a complete key, and the object is its binding, but the
  1019.      binding is not executable as a command.
  1020.  
  1021.    In short, a keymap entry may be a keymap, a command, a keyboard
  1022. macro, a symbol that leads to one of them, or an indirection or `nil'.
  1023. Here is an example of a sparse keymap with two characters bound to
  1024. commands and one bound to another keymap.  This map is the normal value
  1025. of `emacs-lisp-mode-map'.  Note that 9 is the code for TAB, 127 for
  1026. DEL, 27 for ESC, 17 for `C-q' and 24 for `C-x'.
  1027.  
  1028.      (keymap (9 . lisp-indent-line)
  1029.              (127 . backward-delete-char-untabify)
  1030.              (27 keymap (17 . indent-sexp) (24 . eval-defun)))
  1031.  
  1032. 
  1033. File: lispref.info,  Node: Functions for Key Lookup,  Next: Changing Key Bindings,  Prev: Key Lookup,  Up: Keymaps
  1034.  
  1035. Functions for Key Lookup
  1036. ========================
  1037.  
  1038.    Here are the functions and variables pertaining to key lookup.
  1039.  
  1040.  - Function: lookup-key KEYMAP KEY &optional ACCEPT-DEFAULTS
  1041.      This function returns the definition of KEY in KEYMAP.  If the
  1042.      string or vector KEY is not a valid key sequence according to the
  1043.      prefix keys specified in KEYMAP (which means it is "too long" and
  1044.      has extra events at the end), then the value is a number, the
  1045.      number of events at the front of KEY that compose a complete key.
  1046.  
  1047.      If ACCEPT-DEFAULTS is non-`nil', then `lookup-key' considers
  1048.      default bindings as well as bindings for the specific events in
  1049.      KEY.  Otherwise, `lookup-key' reports only bindings for the
  1050.      specific sequence KEY, ignoring default bindings except when you
  1051.      explicitly ask about them.  (To do this, supply `t' as an element
  1052.      of KEY; see *Note Format of Keymaps::.)
  1053.  
  1054.      All the other functions described in this chapter that look up
  1055.      keys use `lookup-key'.
  1056.  
  1057.           (lookup-key (current-global-map) "\C-x\C-f")
  1058.               => find-file
  1059.           (lookup-key (current-global-map) "\C-x\C-f12345")
  1060.               => 2
  1061.  
  1062.      If KEY contains a meta character, that character is implicitly
  1063.      replaced by a two-character sequence: the value of
  1064.      `meta-prefix-char', followed by the corresponding non-meta
  1065.      character.  Thus, the first example below is handled by conversion
  1066.      into the second example.
  1067.  
  1068.           (lookup-key (current-global-map) "\M-f")
  1069.               => forward-word
  1070.           (lookup-key (current-global-map) "\ef")
  1071.               => forward-word
  1072.  
  1073.      Unlike `read-key-sequence', this function does not modify the
  1074.      specified events in ways that discard information (*note Key
  1075.      Sequence Input::.).  In particular, it does not convert letters to
  1076.      lower case and it does not change drag events to clicks.
  1077.  
  1078.  - Command: undefined
  1079.      Used in keymaps to undefine keys.  It calls `ding', but does not
  1080.      cause an error.
  1081.  
  1082.  - Function: key-binding KEY &optional ACCEPT-DEFAULTS
  1083.      This function returns the binding for KEY in the current keymaps,
  1084.      trying all the active keymaps.  The result is `nil' if KEY is
  1085.      undefined in the keymaps.
  1086.  
  1087.      The argument ACCEPT-DEFAULTS controls checking for default
  1088.      bindings, as in `lookup-key' (above).
  1089.  
  1090.      An error is signaled if KEY is not a string or a vector.
  1091.  
  1092.           (key-binding "\C-x\C-f")
  1093.               => find-file
  1094.  
  1095.  - Function: local-key-binding KEY &optional ACCEPT-DEFAULTS
  1096.      This function returns the binding for KEY in the current local
  1097.      keymap, or `nil' if it is undefined there.
  1098.  
  1099.      The argument ACCEPT-DEFAULTS controls checking for default
  1100.      bindings, as in `lookup-key' (above).
  1101.  
  1102.  - Function: global-key-binding KEY &optional ACCEPT-DEFAULTS
  1103.      This function returns the binding for command KEY in the current
  1104.      global keymap, or `nil' if it is undefined there.
  1105.  
  1106.      The argument ACCEPT-DEFAULTS controls checking for default
  1107.      bindings, as in `lookup-key' (above).
  1108.  
  1109.  - Function: minor-mode-key-binding KEY &optional ACCEPT-DEFAULTS
  1110.      This function returns a list of all the active minor mode bindings
  1111.      of KEY.  More precisely, it returns an alist of pairs `(MODENAME .
  1112.      BINDING)', where MODENAME is the variable that enables the minor
  1113.      mode, and BINDING is KEY's binding in that mode.  If KEY has no
  1114.      minor-mode bindings, the value is `nil'.
  1115.  
  1116.      If the first binding is not a prefix command, all subsequent
  1117.      bindings from other minor modes are omitted, since they would be
  1118.      completely shadowed.  Similarly, the list omits non-prefix
  1119.      bindings that follow prefix bindings.
  1120.  
  1121.      The argument ACCEPT-DEFAULTS controls checking for default
  1122.      bindings, as in `lookup-key' (above).
  1123.  
  1124.  - Variable: meta-prefix-char
  1125.      This variable is the meta-prefix character code.  It is used when
  1126.      translating a meta character to a two-character sequence so it can
  1127.      be looked up in a keymap.  For useful results, the value should be
  1128.      a prefix event (*note Prefix Keys::.).  The default value is 27,
  1129.      which is the ASCII code for ESC.
  1130.  
  1131.      As long as the value of `meta-prefix-char' remains 27, key lookup
  1132.      translates `M-b' into `ESC b', which is normally defined as the
  1133.      `backward-word' command.  However, if you set `meta-prefix-char'
  1134.      to 24, the code for `C-x', then XEmacs will translate `M-b' into
  1135.      `C-x b', whose standard binding is the `switch-to-buffer' command.
  1136.  
  1137.           meta-prefix-char                    ; The default value.
  1138.                => 27
  1139.  
  1140.           (key-binding "\M-b")
  1141.                => backward-word
  1142.  
  1143.           ?\C-x                               ; The print representation
  1144.                => 24                          ;   of a character.
  1145.  
  1146.           (setq meta-prefix-char 24)
  1147.                => 24
  1148.  
  1149.           (key-binding "\M-b")
  1150.                => switch-to-buffer            ; Now, typing `M-b' is
  1151.                                               ;   like typing `C-x b'.
  1152.           
  1153.           (setq meta-prefix-char 27)          ; Avoid confusion!
  1154.                => 27                          ; Restore the default value!
  1155.  
  1156.